#ifndef GUI_H
#define GUI_H

#include <QMainWindow>
#include <QPushButton>
#include <QComboBox>
#include <QLineEdit>
#include <QTextEdit>
#include <QSlider>
#include <QProgressBar>
#include <QTimer>

class SerialPort;

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void onOpenPortClicked();
    void onSendDataClicked();
    void onFullScreenClicked();
    void onLeftScreenClicked();
    void onRightScreenClicked();
    void onSettingsClicked();
    void onSliderValueChanged(int value);
    void onProgressValueChanged();
    void handleSerialData(const QByteArray &data);
    void processSerialData();

private:
    void setupUI();
    void setupConnections();

    SerialPort *serialPort;
    QTimer *serialDataTimer;

    // UI elements
    QComboBox *portComboBox;
    QComboBox *baudrateComboBox;
    QPushButton *openPortButton;
    QLineEdit *sendDataEdit;
    QPushButton *sendButton;
    QTextEdit *receiveTextEdit;
    QPushButton *fullScreenButton;
    QPushButton *leftScreenButton;
    QPushButton *rightScreenButton;
    QPushButton *settingsButton;
    QSlider *valueSlider;
    QLineEdit *progressValueEdit;
    QProgressBar *progressBar;

    uint8_t BacklightSwitch = 0;
    uint16_t BacklightValue = 0;
    uint8_t leftScreenState = 1;
    uint8_t rightScreenState = 1;
};

#endif // GUI_H